package com.apes.hr.transfer.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.hr.base.model.*;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import com.apes.scm.masterdata.frame.model.Branch;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * 功能：调动申请 执行表
 * @author FengJiaJing
 * @create 2018-07-31 11:20
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = TransferApplicationExecution.CONST_TABLE_NAME)
public class TransferApplicationExecution  extends Model {
    public static final String CONST_TABLE_NAME = "hr_transfer_execution";
    //
    @Id
    @Column(name = "id",nullable = false, length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "执行表号")
    private String id; //调动单号

    @OneToOne(fetch=FetchType.LAZY)//(fetch = FetchType.LAZY,cascade=CascadeType.ALL)
    @JoinColumn(name = "transferApplication_item_id",  nullable = false) //referencedColumnName = "id",
    private TransferApplicationItem transferApplicationItems;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "transfer_type",  referencedColumnName = "id")
    private Enumeration hrTransferType; //调动类型(0:调动;1:支援)

    @Column(name = "effective_date")
    private Date effectiveDate; //生效日期

    @Column(name = "end_date")
    private Date endDate; //支援结束日期

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "transfer_uid", referencedColumnName = "id")
    private Employee transferUid; //人员编码

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "branch_id", referencedColumnName = "id")
    private Branch branch; // 部门

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "job_id", referencedColumnName = "id")
    private Job job; //职位

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "post_id", referencedColumnName = "id")
    private WorkPost workPost; // 岗位

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "rank_id", referencedColumnName = "id")
    private Rank rankId; // 职级

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "on_duty_id_after", referencedColumnName = "id")
    private Enumeration onDutyState; // 调动后在岗状态:(0:试用期;1:代理期;2:待岗期;3:实习期;4:转正;5:长假;9:支援期)

//    @ManyToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name = "person_group", referencedColumnName = "id")
//    private PersonGroup personnelGroupingId; // 人员分组(1:店长;2:储备店长;3:服务顾问;4:储备服务顾问-社招;5:储备服务顾问-校招;6:助理;7:美容主管;8:美容组员工;9:机电主管;10:机电组员工;11:钣金主管;12:钣金组员工;13:喷漆主管;14:喷漆组员工;15:门卫;16:调度司机;17:残联;18:临时工-含暑假工\装修小工\劳务工;19:董事长;20:副总裁;21:总经理;22:副总经理;23:总监;24:经理;25:职能主管;26:职能主管级以下;27:小时工;28:助理区长;29:波箱王;30:兼职;31:副总监;32:职能副经理;33:职能副主管)

    @Column(name = "staff_share",  nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4)
    private double staffShare = 0; //份数 份额

}
